﻿using System;
using System.Data;
using System.Globalization;
using System.Text;

namespace LCI
{
    internal class Program
    {
        internal static void Main()
        {
            Char[] TChars = new Char[] { ' ', ',' };
            DataTable DTResult = new DataTable("CultureInfos");
            DTResult.Columns.Add("Name", typeof(String));
            DTResult.Columns.Add("Two_Letter_ISO_Language_Name", typeof(String));
            DTResult.Columns.Add("Three_Letter_ISO_Language_Name", typeof(String));
            DTResult.Columns.Add("Three_Letter_Windows_Language_Name", typeof(String));
            DTResult.Columns.Add("Display_Name", typeof(String));
            DTResult.Columns.Add("English_Name", typeof(String));
            DTResult.Columns.Add("Native_Name", typeof(String));
            DTResult.Columns.Add("LCID", typeof(String));
            DTResult.Columns.Add("Day_Names", typeof(String));
            DTResult.Columns.Add("Abbreviated_Day_Names", typeof(String));
            DTResult.Columns.Add("Month_Names", typeof(String));
            DTResult.Columns.Add("Abbreviated_Month_Names", typeof(String));
            DTResult.Columns.Add("AM_PM_Designator", typeof(String));
            DTResult.Columns.Add("Calendar_Algorithm_Type", typeof(String));
            DTResult.Columns.Add("Calendar_Week_Rule", typeof(String));
            DTResult.Columns.Add("Date_Separator", typeof(String));
            DTResult.Columns.Add("Time_Separator", typeof(String));
            DTResult.Columns.Add("First_Day_Of_Week", typeof(String));
            DTResult.Columns.Add("Full_Date_Time_Pattern", typeof(String));
            DTResult.Columns.Add("Long_Date_Pattern", typeof(String));
            DTResult.Columns.Add("Long_Time_Pattern", typeof(String));
            DTResult.Columns.Add("Month_Day_Pattern", typeof(String));
            DTResult.Columns.Add("RFC_1123_Pattern", typeof(String));
            DTResult.Columns.Add("Shortest_Day_Pattern", typeof(String));
            DTResult.Columns.Add("Short_Time_Pattern", typeof(String));
            DTResult.Columns.Add("Sortable_Date_Time_Pattern", typeof(String));
            DTResult.Columns.Add("Universal_Sortable_Date_Time_Pattern", typeof(String));
            DTResult.Columns.Add("Year_Month_Pattern", typeof(String));
            DTResult.Columns.Add("Currency_Decimal_Digits", typeof(String));
            DTResult.Columns.Add("Currency_Decimal_Separator", typeof(String));
            DTResult.Columns.Add("Currency_Group_Separator", typeof(String));
            DTResult.Columns.Add("Currency_Group_Sizes", typeof(String));
            DTResult.Columns.Add("Currency_Negative_Pattern", typeof(String));
            DTResult.Columns.Add("Currency_Positive_Pattern", typeof(String));
            DTResult.Columns.Add("Currency_Symbol", typeof(String));
            DTResult.Columns.Add("Digit_Substitution", typeof(String));
            DTResult.Columns.Add("NaN_Symbol", typeof(String));
            DTResult.Columns.Add("Native_Digits", typeof(String));
            DTResult.Columns.Add("Negative_Infinity_Symbol", typeof(String));
            DTResult.Columns.Add("Negative_Sign", typeof(String));
            DTResult.Columns.Add("Number_Decimal_Digits", typeof(String));
            DTResult.Columns.Add("Number_Decimal_Separator", typeof(String));
            DTResult.Columns.Add("Number_Group_Separator", typeof(String));
            DTResult.Columns.Add("Number_Group_Sizes", typeof(String));
            DTResult.Columns.Add("Number_Negative_Pattern", typeof(String));
            DTResult.Columns.Add("Percent_Decimal_Digits", typeof(String));
            DTResult.Columns.Add("Percent_Decimal_Separator", typeof(String));
            DTResult.Columns.Add("Percent_Group_Separator", typeof(String));
            DTResult.Columns.Add("Percent_Group_Sizes", typeof(String));
            DTResult.Columns.Add("Percent_Negative_Pattern", typeof(String));
            DTResult.Columns.Add("Percent_Positive_Pattern", typeof(String));
            DTResult.Columns.Add("Percent_Symbol", typeof(String));
            DTResult.Columns.Add("PerMille_Symbol", typeof(String));
            DTResult.Columns.Add("Positive_Infinity_Symbol", typeof(String));
            DTResult.Columns.Add("Positive_Sign", typeof(String));
            DTResult.Columns.Add("ANSI_Code_Page", typeof(String));
            DTResult.Columns.Add("EBCDIC_Code_Page", typeof(String));
            DTResult.Columns.Add("Is_Right_To_Left", typeof(String));
            DTResult.Columns.Add("List_Separator", typeof(String));
            DTResult.Columns.Add("Mac_Code_Page", typeof(String));
            DTResult.Columns.Add("OEM_Code_Page", typeof(String));

            CultureInfo[] CIValues = CultureInfo.GetCultures(CultureTypes.AllCultures);
            StringBuilder SBValue = new StringBuilder(); DataRow DRValue;
            DateTimeFormatInfo DTFI; NumberFormatInfo NFI; TextInfo TI;
            foreach (CultureInfo CIValue in CIValues)
            {
                DRValue = DTResult.NewRow(); DTFI = CIValue.DateTimeFormat;
                NFI = CIValue.NumberFormat; TI = CIValue.TextInfo;
                DRValue["Name"] = CIValue.Name;
                DRValue["Two_Letter_ISO_Language_Name"] = CIValue.TwoLetterISOLanguageName;
                DRValue["Three_Letter_ISO_Language_Name"] = CIValue.ThreeLetterISOLanguageName;
                DRValue["Three_Letter_Windows_Language_Name"] = CIValue.ThreeLetterWindowsLanguageName;
                DRValue["Display_Name"] = CIValue.DisplayName;
                DRValue["English_Name"] = CIValue.EnglishName;
                DRValue["Native_Name"] = CIValue.NativeName;
                DRValue["LCID"] = CIValue.LCID.ToString();
                for (Int32 N = 0; N < 7; N++) SBValue.Append(DTFI.DayNames[N] + ", ");
                DRValue["Day_Names"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                for (Int32 N = 0; N < 7; N++) SBValue.Append(DTFI.AbbreviatedDayNames[N] + ", ");
                DRValue["Abbreviated_Day_Names"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                for (Int32 N = 0; N < 12; N++) SBValue.Append(DTFI.MonthNames[N] + ", ");
                DRValue["Month_Names"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                for (Int32 N = 0; N < 12; N++) SBValue.Append(DTFI.AbbreviatedMonthNames[N] + ", ");
                DRValue["Abbreviated_Month_Names"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                DRValue["AM_PM_Designator"] = $"{DTFI.AMDesignator},_{DTFI.PMDesignator}";
                DRValue["Calendar_Algorithm_Type"] = DTFI.Calendar.AlgorithmType.ToString();
                DRValue["Calendar_Week_Rule"] = DTFI.CalendarWeekRule.ToString();
                DRValue["Date_Separator"] = DTFI.DateSeparator;
                DRValue["Time_Separator"] = DTFI.TimeSeparator;
                DRValue["First_Day_Of_Week"] = DTFI.FirstDayOfWeek.ToString();
                DRValue["Full_Date_Time_Pattern"] = DTFI.FullDateTimePattern;
                DRValue["Long_Date_Pattern"] = DTFI.LongDatePattern;
                DRValue["Long_Time_Pattern"] = DTFI.LongTimePattern;
                DRValue["Month_Day_Pattern"] = DTFI.MonthDayPattern;
                DRValue["RFC_1123_Pattern"] = DTFI.RFC1123Pattern;
                for (Int32 N = 0; N < DTFI.ShortDatePattern.Length; N++) SBValue.Append(DTFI.ShortDatePattern[N] + ", ");
                DRValue["Shortest_Day_Pattern"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                DRValue["Short_Time_Pattern"] = DTFI.ShortTimePattern;
                DRValue["Sortable_Date_Time_Pattern"] = DTFI.SortableDateTimePattern;
                DRValue["Universal_Sortable_Date_Time_Pattern"] = DTFI.UniversalSortableDateTimePattern;
                DRValue["Year_Month_Pattern"] = DTFI.YearMonthPattern;
                DRValue["Currency_Decimal_Digits"] = NFI.CurrencyDecimalDigits.ToString();
                DRValue["Currency_Decimal_Separator"] = NFI.CurrencyDecimalSeparator;
                DRValue["Currency_Group_Separator"] = NFI.CurrencyGroupSeparator;
                for (Int32 N = 0; N < NFI.CurrencyGroupSizes.Length; N++) SBValue.Append(NFI.CurrencyGroupSizes[N].ToString() + ", ");
                DRValue["Currency_Group_Sizes"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                DRValue["Currency_Negative_Pattern"] = NFI.CurrencyNegativePattern.ToString();
                DRValue["Currency_Positive_Pattern"] = NFI.CurrencyPositivePattern.ToString();
                DRValue["Currency_Symbol"] = NFI.CurrencySymbol;
                DRValue["Digit_Substitution"] = NFI.DigitSubstitution.ToString();
                DRValue["NaN_Symbol"] = NFI.NaNSymbol;
                for (Int32 N = 0; N < 10; N++) SBValue.Append(NFI.NativeDigits[N] + ", ");
                DRValue["Native_Digits"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                DRValue["Negative_Infinity_Symbol"] = NFI.NegativeInfinitySymbol;
                DRValue["Negative_Sign"] = NFI.NegativeSign;
                DRValue["Number_Decimal_Digits"] = NFI.NumberDecimalDigits.ToString();
                DRValue["Number_Decimal_Separator"] = NFI.NumberDecimalSeparator;
                DRValue["Number_Group_Separator"] = NFI.NumberGroupSeparator;
                for (Int32 N = 0; N < NFI.NumberGroupSizes.Length; N++) SBValue.Append(NFI.NumberGroupSizes[N].ToString() + ", ");
                DRValue["Number_Group_Sizes"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                DRValue["Number_Negative_Pattern"] = NFI.NumberNegativePattern.ToString();
                DRValue["Percent_Decimal_Digits"] = NFI.PercentDecimalDigits.ToString();
                DRValue["Percent_Decimal_Separator"] = NFI.PercentDecimalSeparator;
                DRValue["Percent_Group_Separator"] = NFI.PercentGroupSeparator;
                for (Int32 N = 0; N < NFI.PercentGroupSizes.Length; N++) SBValue.Append(NFI.PercentGroupSizes[N].ToString() + ", ");
                DRValue["Percent_Group_Sizes"] = SBValue.ToString().Trim(TChars); SBValue.Clear();
                DRValue["Percent_Negative_Pattern"] = NFI.PercentNegativePattern.ToString();
                DRValue["Percent_Positive_Pattern"] = NFI.PercentPositivePattern.ToString();
                DRValue["Percent_Symbol"] = NFI.PercentSymbol;
                DRValue["PerMille_Symbol"] = NFI.PerMilleSymbol;
                DRValue["Positive_Infinity_Symbol"] = NFI.PositiveInfinitySymbol;
                DRValue["Positive_Sign"] = NFI.PositiveSign;
                DRValue["ANSI_Code_Page"] = TI.ANSICodePage.ToString();
                DRValue["EBCDIC_Code_Page"] = TI.EBCDICCodePage.ToString();
                DRValue["Is_Right_To_Left"] = TI.IsRightToLeft.ToString();
                DRValue["List_Separator"] = TI.ListSeparator;
                DRValue["Mac_Code_Page"] = TI.MacCodePage.ToString();
                DRValue["OEM_Code_Page"] = TI.OEMCodePage.ToString();
                DTResult.Rows.Add(DRValue);
            }
            DTResult.WriteXml("CultureInfos.xml", XmlWriteMode.WriteSchema, false);
            Console.WriteLine($"Load {DTResult.Rows.Count} Cultures Info.");
            Console.WriteLine($"Save to CultureInfos.xml");
            Console.ReadKey();
        }
    }
}
